package com.lkj.youmeng.adapter;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.lkj.youmeng.base.BaseFragment;

import java.util.List;

/**
 * @作者：JAY
 * @创建时间：2020/3/9 14:39
 * @描述：
 **/
public class PagerAdapter extends FragmentPagerAdapter {
    private String TAG = "PagerAdapter";
    //添加fragment的集合
    private List<BaseFragment> mFragmentList;
    //添加标题的集合
    private List<String> mTitleList;

    public PagerAdapter(FragmentManager fm, List<BaseFragment> fragmentList, List<String> titleList) {
        super(fm);
        mFragmentList = fragmentList;
        mTitleList = titleList;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleList.get(position);
    }
}
